package demo1;
class Animal {
    public String name;
    public int  age;

    /*public Animal() {

    }*/

    static {
        System.out.println("Animal::static{}");
    }

    {
        System.out.println("Animal::{}");
    }
    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("Animal(String , int )");
    }

    public  void eat() {
        System.out.println(name + "吃饭！");
    }

    public void function() {
        System.out.println("Animal::function()!");
    }

}

class Dog extends Animal {
    //傻狗  是狗的属性
    public boolean silly;
    //public String name = "hello";

   /* public Dog() {
        super();
    }*/

    static {
        System.out.println("Dog::static{}");
    }

    {
        System.out.println("Dog::{}");
    }

    public Dog(String name,int age,boolean silly) {
        //1. 先帮助父类部分初始化 必须放到第一行
        super(name,age);
        //super(); 不写 默认都会有
        this.silly = silly;
        System.out.println("Dog(String ,int ,boolean )");
    }

    public void houseGuard () {
        System.out.println(super.name+"正在看家护院！");
        //实例内部当中 才会包含外部类的this
        //System.out.println(Animal.this.name+"正在看家护院！");
        //eat();
        staticFunc();
    }

    public static void staticFunc() {
        //System.out.println(super.name);
    }

    @Override
    public void eat() {
        System.out.println(name+"正在吃狗粮！");
    }


}
class Cat extends Animal {


    /*static {
        System.out.println("Cat::static{}");
    }

    {
        System.out.println("Cat::{}");
    }*/


    public Cat() {
        super("咪咪",10);
        //this("咪咪",10);
        System.out.println("Cat()");
    }

    public Cat(String name,int age) {
        super(name,age);
    }

    //不加特有的属性了
    public void catchMouse() {
        System.out.println(name + "抓老鼠！");
    }

    @Override
    public void eat() {
        System.out.println(name+" 吃猫粮 ！");
    }
}

public class Test1 {


    public static void main(String[] args) {
        Dog dog = new Dog("hello",10,false);

    }
}